<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>重新发送短信</title>
    <style>
        *{
            margin: 0px;padding: 0px;
        }
    </style>
</head>
<body>
    <form action="#">
        <input type="text">
        <button id="button">点击发送短信</button>
    </form>
    <script type="text/javascript">
        var button = document.getElementById("button");
        var count = 5;
        var timer = null;
        button.onclick = function () {
            clearInterval(timer)//为了防止在运行过程中，重复点击计时器，加快速度，所以在每次点击的时候，都要清除上一次的计时器
            this.disabled = true;
            var btn_this = this;
           var timer =  setInterval(countTime,1000);
            function countTime() {
                if(count<=0){
                    btn_this.disabled = false;
                    btn_this.innerHTML = "点击发送短信";
                    clearInterval(timer);
                    count = 5;

                }else{
                    count--;
                    btn_this.innerHTML = "还剩"+count+"秒";
                }
            }
        }

    </script>

</body>
</html>